package com.gl.rent;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.haixiaoke.saas.repository.core.AjaxResult;
import com.haixiaoke.saas.repository.core.BaseController;
import com.haixiaoke.saas.repository.core.page.TableDataInfo;
import com.haixiaoke.saas.repository.pojo.OrderOperatingRecord;
import com.haixiaoke.saas.repository.service.IOrderOperatingRecordService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 订单记录Controller
 * 
 * @author haixiaoke
 * @date 2023-04-12
 */
@RestController
@RequestMapping("/biz/record")
public class OrderOperatingRecordController extends BaseController {
    @Autowired
    private IOrderOperatingRecordService orderOperatingRecordService;

    /**
     * 查询订单记录列表
     */
//    @PreAuthorize("@ss.hasPermi('saas-repository:record:list')")
    @GetMapping("/list")
    public TableDataInfo list(OrderOperatingRecord orderOperatingRecord) {
        startPage();
        List<OrderOperatingRecord> list = orderOperatingRecordService.selectOrderOperatingRecordList(orderOperatingRecord);
        return getDataTable(list);
    }

    /**
     * 获取订单记录详细信息
     */
//    @PreAuthorize("@ss.hasPermi('saas-repository:record:query')")
    @GetMapping(value = "/{orderRecordId}")
    public AjaxResult getInfo(@PathVariable("orderRecordId") Long orderRecordId) {
        return success(orderOperatingRecordService.selectOrderOperatingRecordByOrderRecordId(orderRecordId));
    }

    /**
     * 新增订单记录
     */
//    @PreAuthorize("@ss.hasPermi('saas-repository:record:add')")
//    @Log(title = "订单记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OrderOperatingRecord orderOperatingRecord) {
        return toAjax(orderOperatingRecordService.insertOrderOperatingRecord(orderOperatingRecord));
    }

    /**
     * 修改订单记录
     */
//    @PreAuthorize("@ss.hasPermi('saas-repository:record:edit')")
//    @Log(title = "订单记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OrderOperatingRecord orderOperatingRecord) {
        return toAjax(orderOperatingRecordService.updateOrderOperatingRecord(orderOperatingRecord));
    }

    /**
     * 删除订单记录
     */
//    @PreAuthorize("@ss.hasPermi('saas-repository:record:remove')")
//    @Log(title = "订单记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{orderRecordIds}")
    public AjaxResult remove(@PathVariable Long[] orderRecordIds) {
        return toAjax(orderOperatingRecordService.deleteOrderOperatingRecordByOrderRecordIds(orderRecordIds));
    }
}
